home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / cl0588.zip / STACK.C < prev    next >
Text File  |  1987-01-03  |  520b  |  38 lines

  1. /* .subt | stack routines for the desktop calculator */
  2.  
  3. #define MAXVAL 100
  4.  
  5. int  sp = 0;
  6. double  val[MAXVAL];
  7.  
  8. double push(f)
  9. double f;
  10. {
  11.   if (sp < MAXVAL)
  12.        return(val[sp++] = f);
  13.   else {
  14.        printf("error: stack full\n");
  15.        clear();
  16.        return(0.0);
  17.   }
  18. }
  19.  
  20. double pop()
  21. {
  22.   if (sp > 0)
  23.        return(val[--sp]);
  24.   else {
  25.        printf("error: stack empty\n");
  26.        clear();
  27.        return(0.0);
  28.   }
  29. }
  30.  
  31. clear()
  32. {
  33.   sp = 0;
  34. }
  35.  
  36. /* .subt < end of file, stack.c */
  37.  
  38.